Skip to content

Hint type blind spots - #6307

Closed
AJenbo wants to merge 1 commit into
phpstan:2.3.xfrom
AJenbo:types
Closed

AJenbo wants to merge 1 commit into
phpstan:2.3.xfrom
AJenbo:types

Conversation

@AJenbo

@AJenbo AJenbo commented Aug 30, 2026

Copy link
Copy Markdown
Contributor

This adds hints where ever variables with out a known type is used, basically this is the benefit of level 9 + 10 without having to pay the high tax.

No real issues where found, the only thing else here is the removal of a couple of redundant calls in src/Analyser/NodeScopeResolver.php.

@AJenbo
AJenbo changed the base branch from 2.2.x to 2.3.x October 23, 2026 14:31
* @param array<string, array<string>>|null $dependencies
* @param array<string, array<string>>|null $usedTraitDependencies
* @param ValueDependencies|null $valueDependencies
* @param array<string, array<string>>|null $packageDependencies

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This certainly isn't needed with the new feature that analyses closures based on each usage. Feel free to test this with dumpType inside the closure.

/** @var Node\Arg[]|null $arrayMapArgs */
$arrayMapArgs = $expr->getAttribute(ArrayMapArgVisitor::ATTRIBUTE_NAME);
/** @var Node\Arg[]|null $immediatelyInvokedArgs */
$immediatelyInvokedArgs = $expr->getAttribute(ImmediatelyInvokedClosureVisitor::ARGS_ATTRIBUTE_NAME);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I feel like this would be better addressed with a dynamic return type extension for getAttribute / getAttributes dynamic return type extension. We could even implement a new extension interface to be implemented alongside NodeVisitor for current rich parser visitors, to inform the extension.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants